#[cfg(feature = "ssr")]
mod evaluator;
#[cfg(feature = "ssr")]
mod parser;
#[cfg(feature = "ssr")]
use aho_corasick::AhoCorasick;
#[cfg(feature = "ssr")]
pub use evaluator::*;
#[cfg(feature = "ssr")]
pub use parser::get_exp_col_names;
#[cfg(feature = "ssr")]
pub fn parse_exp(exp: &str, params: &[(&str, &str)]) -> anyhow::Result<String> {
    if !exp.contains("@") {
        return Ok(exp.to_string());
    }
    let params_names: Vec<String> = params
        .iter()
        .map(|(k, _)| {
            format!("@{}", k)
        })
        .collect();
    let params_vals: Vec<&str> = params.iter().map(|(_, v)| *v).collect();
    let ac = AhoCorasick::builder().build(params_names)?;
    let mut wtr = vec![];
    ac.try_stream_replace_all(exp.as_bytes(), &mut wtr, &params_vals)
        .expect("字符串替换失败");
    let vstr = String::from_utf8(wtr)?;
    Ok(vstr)
}


